package com.czy.owner.ui.business;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.czy.owner.entity.BusinessCategoryModel;
import com.czy.owner.ui.BaseFragment;

import java.util.List;

/**
 * Created by Raven on 2017/12/13.
 */

public class BusinessFragmentAdapter extends FragmentStatePagerAdapter {

    private List<BusinessCategoryModel> mDatas;
    private List<BaseFragment> fragments;

    public BusinessFragmentAdapter(FragmentManager fm , List<BaseFragment> fragments ,List<BusinessCategoryModel> datas ) {
        super(fm);
        this.mDatas = datas;
        this.fragments = fragments;
    }

    @Override
    public Fragment getItem(int i) {
        return fragments.get(i);
    }

    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mDatas.get(position).getServiceName();
    }

    public void reloadFragment(int position){
        fragments.get(position).reloadData();
    }
}
